package com.xx.eshop.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


import com.xx.eshop.dao.AttrValueDao;
import com.xx.eshop.entity.Attr;
import com.xx.eshop.entity.AttrValue;
import com.xx.eshop.service.AttrValueService;

@Service
public class AttrValueServiceImpl implements AttrValueService{

	@Autowired
	private AttrValueDao valueDao;

	
	public int findNextId(int cid){
		int vid = valueDao.findNextId(cid);
		return vid;
	};
	
	@Override
	public void save(AttrValue value) {
		// TODO Auto-generated method stub
		valueDao.save(value);
	}

	@Override
	public List<AttrValue> findByAttr(int aid) {
		// TODO Auto-generated method stub
		return valueDao.findByAttr(aid);
	}
	
	@Override
	public List<AttrValue> findByAttr2(int aid) {
		// TODO Auto-generated method stub
		return valueDao.findByAttr(aid);
	}

	@Override
	public List<AttrValue> findByAttrFetch(int aid) {
		// TODO Auto-generated method stub
		return valueDao.findByAttrFetch(aid);
	}

	@Override
	public AttrValue findOne(int id) {
		// TODO Auto-generated method stub
		return valueDao.findOne(id);
	}

	@Override
	public AttrValue updateSort(int valueId, int valueSort) {
		// TODO Auto-generated method stub
		System.out.println("service 中的---valueSort"+valueSort);
		AttrValue avalue = valueDao.findOne(valueId);
		System.out.println("====service 中："+avalue.toString());
		avalue.setSort(valueSort);
		valueDao.update(avalue);
		return avalue;
	}

	@Override
	public void delete(int id) {
		valueDao.delete(id);
	}

	@Override
	public void update(AttrValue value) {
		valueDao.update(value);
	}
	
	
}
